<div class="wrapper">
    <?php echo form_open('grading/sections/delete',array('id'=>'form')); ?>
	<table class="table-grid  float-left">
    	<thead>
        	<tr>
            	<th class="action-width"><input type="checkbox" id="select-all" /></th>
            	<th><?php echo lang('school_year_section_name'); ?></th>
				<th></th>
            </tr>
        </thead>
        <tbody>
        <?php
            $i      = 0;
            $tmp    = '';
        ?>
        <?php foreach($school_year->section_listings as $s) : ?>
            <?php $s->school_levels->get(); ?>
            <?php if($tmp!=$s->school_levels->id) : ?>
                <tr>
                    <td class="align-left" colspan='3'><?php echo $s->school_levels->name; ?></td>
                </tr>
                 <?php $tmp = $s->school_levels->id; ?>
            <?php endif; ?>
        	<tr class="<?php echo ($i%2) ? 'odd' : 'even'; ?>">
            	<td class="align-center"><input type="checkbox" name="section_id[]" value="<?php echo $s->id; ?>" /></td>
            	<td class="align-left"><?php echo $s->section_name; ?></td>
				<td class="align-center">
					
					<a href="<?php echo site_url('grading/school_year/student_listings/'.$s->id.'/'.$school_year->year); ?>" rel='<?php echo $s->id; ?>' class='btn btn-students' title="<?php echo lang('school_year_students'); ?>">
						<span class="btn-icon students-icon"></span>
						<?php echo lang('school_year_students'); ?>
						( <?php echo $s->students->get()->result_count(); ?> )
					</a>
					
					<a href="<?php echo site_url('grading/school_year/subject_listings/'.$s->id.'/'.$s->school_levels->id.'/'.$school_year->year); ?>" rel='<?php echo $s->id; ?>' class='btn btn-subject' title="<?php echo lang('school_year_subject_name'); ?>">
						<span class="btn-icon subject-icon"></span>
						<?php echo lang('school_year_subject_name'); ?>
						( <?php echo $s->school_levels->subject_listings->where('school_year_id',$school_year->id)->get()->result_count(); ?> )
					</a>
					
				</td>
            </tr>
            
            <?php $i++; ?>
        <?php endforeach; ?>
        </tbody>
    </table>
    
    <?php echo form_close(); ?>
</div>
<script>
$('#select-all').click(function(){
	$("input[type='checkbox']").attr('checked', $(this).is(':checked'));   
});

$('.btn').click(function(){
	$.facebox.settings.closeImage = '<?php echo image_path('facebox/closelabel.png'); ?>';
	$.facebox({
		ajax		 : $(this).attr('href')
	});
	return false;
});

$(document).ready(function() {
<?php if($this->session->flashdata('msg')) : ?>
	$.notificationBox("<?php echo $this->session->flashdata('msg_title'); ?>","<?php echo $this->session->flashdata('msg'); ?>");
<?php endif; ?>

	$('#del_button').click(function(){
		
		if($('#form input:checked').is(':checked'))
		{
			$('#form').submit();
		} else {
		}
		
		return false;
	});
});
</script>